package org.example;

import org.example.service.OrderService;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class Main {
    public static void main(String[] args) {
        // 初始化Spring容器
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
        OrderService orderService = context.getBean(OrderService.class);

        // 测试AOP增强效果
        System.out.println("=== 测试add方法 ===");
        try {
            orderService.add("笔记本电脑", 1);
        } catch (RuntimeException e) {
            System.out.println("add方法执行失败: " + e.getMessage());
        }

        System.out.println("\n=== 测试delete方法 ===");
        try {
            orderService.delete("笔记本电脑");
        } catch (RuntimeException e) {
            System.out.println("delete方法执行失败: " + e.getMessage());
        }

        System.out.println("\n=== 测试find方法 ===");
        orderService.find("笔记本电脑");

        context.close();
    }
}
